﻿using System;
using System.Collections.Generic;
using System.Linq;
using Students; 

class OrderByThenBy : Student
{

    //Using the extension methods OrderBy() 
    //and ThenBy() with lambda expressions sort 
    //the students by first name and last name 
    //in descending order. Rewrite the same with LINQ.

    public OrderByThenBy() : base(null, null) { }
    static void Main()
    {
        List<Student> students = new List<Student>();
        students.Add(new Student("Asho", "Bitoff"));
        students.Add(new Student("Besho", "Gurov"));
        students.Add(new Student("Asho", "Genov"));

        var sortedList = students.OrderByDescending(x => x.Fname).ThenByDescending(y => y.Lname);
        foreach (var item in sortedList)
        {
            Console.WriteLine("{0} {1}", item.Fname, item.Lname);
        }

        var sortLINQ =
            from x in students
            orderby x.Fname descending
            orderby x.Lname descending
            select x;
        foreach (var item in sortLINQ)
        {
            Console.WriteLine("{0} {1}", item.Fname, item.Lname);
        }
    }
}